package com.example.project.webControlleer;

import com.example.project.dao.ParkingDAO;
import com.example.project.pojo.Car;
import com.example.project.pojo.Parking;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;


@Controller
@RequestMapping("web")
public class WebUpdatePrivateParkingController {
    @RequestMapping("updatePrivateParking")
    public String updatePrivateParking(int pId,String license, Model model){
        ParkingDAO parkingDAO=new ParkingDAO();
        List<Car> licenseList=parkingDAO.showAllLicense(license);
        Parking parking =parkingDAO.showLicense(pId);
        model.addAttribute("parking",parking);
        model.addAttribute("licenseList",licenseList);
        return "web/updatePriParking";
    }
    @GetMapping("upLicense")
    public String upLicense(String license,int parkingId){

        ParkingDAO parkingDAO =new ParkingDAO();
        parkingDAO.upParkingLicense(license,parkingId);
        return "redirect:findPrivateParking";
    }
}
